import { EnumViewMode } from "@renderer/assets/types";

type ITabType = EnumViewMode | "tag" | "setting";
export const idHelper = {
  createViewId: ({ seriesId, viewMode, viewType }, index = 0) => {
    return `viewId__${seriesId}__${viewMode}__${viewType}__${index}`;
  },
  generateNewTabId({
    patientUID,
    seriesId,
    tabType,
    viewMode = "",
  }: {
    patientUID?: string;
    seriesId?: string;
    tabType: ITabType;
    viewMode?: string;
    viewType?: string;
  }): string {
    if (tabType === "tag") {
      return `tabId__${tabType}__${patientUID}__${seriesId}`;
    } else if (tabType === "setting") {
      return `tabId__${tabType}`;
    }
    return `tabId__${tabType}__${patientUID}__${seriesId}__${viewMode}`;
  },
  resolveTabId(tabId: string): any {
    const [_,tabType, patientUID, seriesId, viewMode, viewType] =
      tabId.split("__");
    return {
      tabType,
      patientUID,
      seriesId,
      viewMode,
      viewType,
    };
  },
};
